<?php

class Application_Model_Devices extends Zend_Db_Table_Abstract
{
    protected $_name = "kp_devices"; //Ten bang
    protected $_primary = "dv_id"; //Khoa chinh
    protected $db;
    //Cac truong du lieu
    var $dv_id;
    var $app_id;
    var $os_id;
    var $vos_id;
    var $cp_id;
    
    //Ham khoi tao
    public function __construct(){
        $this->db = Zend_Registry::get('db');
    }
    
    //Get all user
    public function getAll($status=-1){
        $query = $this->db->select();
        $query->from($this->_name);
        if($status!=-1)$query->where('cat_status = ?',$status);
        $query->order(array('cat_name'));
        return $this->db->fetchAll($query);
    }
    
    //Them mới user
    public function insertNew(){
        $data = array(
                'app_id' => $this->app_id,
                'os_id' => $this->os_id,
                'vos_id'=>$this->vos_id,
                'cp_id'=>$this->cp_id,
        );
        //var_dump($data); die;
        return $this->db->insert($this->_name,$data);
    }

}

